package futbol.tacticas.concursantes.qualitycode.opponent;

import java.awt.Point;

import futbol.General;
import futbol.tacticas.concursantes.qualitycode.QCodeTactica;
import futbol.tacticas.concursantes.qualitycode.common.QPlayer;
import futbol.tacticas.concursantes.qualitycode.common.QUtils;

public class QOpponentPlayer extends QPlayer
{
  protected final Point prevPos   = new Point(QCodeTactica.INVALID, QCodeTactica.INVALID);
  
  public QOpponentPlayer(int id)
  {
    super(id);
  }
  
  public QOpponentPlayer(QOpponentPlayer player)
  {
    super(player);
    this.prevPos.setLocation(player.prevPos);
    
  }
  
  public void reset()
  {
    super.reset();
    prevPos.setLocation(QCodeTactica.INVALID, QCodeTactica.INVALID);
    x = QCodeTactica.INVALID;
    y = QCodeTactica.INVALID;
    force = QCodeTactica.FORCE_7_MAX; 
  }
  
  public void updatePos(Point point)
  {
    prevPos.setLocation(x,y);
    super.updatePos(point);    
    
    if (QUtils.isValid(prevPos) && (prevPos.x != (int)x || prevPos.y != (int)y))
    {
      final int dist = (int)General.getDistancia(prevPos.x, prevPos.y, (int)x, (int)y);
      if (dist > speed())
      {
        force = 10 - dist;
      } 
    }
  }  
}
















